#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <vector>
#include "sort.h"
#include <iostream>
using namespace std;

void Test1(){
	const int N = 20;
  vector<vector<int>> vv;
  vv.resize(5);
  for(vector<int>& e:vv){
    e.resize(N);
  }
	for (int i = 0; i < N; ++i)
	{
    int randnum = rand()%100;
		vv[0][i] = randnum;
		vv[1][i] = randnum;
		vv[2][i] = randnum;
		vv[3][i] = randnum;
		vv[4][i] = randnum;
	}

	//InsertSort(vv[0]);
	//ShellSort(vv[1]);
	//HeapSort(vv[2]);
	//QuickSort(vv[3]);
	MergeSort(vv[4]);
  
  for(size_t i = 0; i<vv.size(); ++i)
  {
    cout << i << ": ";
    for(int e:vv[i])
    {
      cout << e << " "; 
    }
    cout << endl;
  }
  cout << endl;

}

void Test2(){
	const int N = 1000000;
	vector<int> a1; a1.resize(N);
	vector<int> a2; a2.resize(N);
	vector<int> a3; a3.resize(N);
	vector<int> a4; a4.resize(N);
	vector<int> a5; a5.resize(N);

	for (int i = 0; i < N; ++i)
	{
		a1[i] = rand();
		a2[i] = a1[i];
		a3[i] = a1[i];
		a4[i] = a1[i];
		a5[i] = a1[i];
	}

	int begin1 = clock();
	//InsertSort(a1);
	int end1 = clock();

	int begin2 = clock();
	//ShellSort(a2);
	int end2 = clock();

	int begin4 = clock();
	//HeapSort(a3);
	int end4 = clock();

	int begin5 = clock();
	//QuickSort(a4);
	int end5 = clock();

	int begin6 = clock();
	MergeSort(a5);
	int end6 = clock();

	printf("InsertSort:%d\n", (int)((float)(end1 - begin1)/CLOCKS_PER_SEC*1000));
	printf("ShellSort:%d\n",  (int)((float)(end2 - begin2)/CLOCKS_PER_SEC*1000));
	printf("HeapSort:%d\n",   (int)((float)(end4 - begin4)/CLOCKS_PER_SEC*1000));
	printf("QuickSort:%d\n",  (int)((float)(end5 - begin5)/CLOCKS_PER_SEC*1000));
	printf("MergeSort:%d\n",  (int)((float)(end6 - begin6)/CLOCKS_PER_SEC*1000));
}

int main(){
	srand(time(0));
  Test1();
	Test2();
 return 0;
}

